<!DOCTYPE html>
<html>
<head>
    <title>Search Results</title>
    <style>
        /* 输入框和按钮的美化（可选） */
        .search-form input {
            padding: 10px;
            width: 900px;
            margin-right: 10px;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        .search-form button {
            padding: 10px 20px;
            background: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }


         table {
            width: 100%;
            border-collapse: collapse;
            /*table-layout: fixed;*/
        }
        th,td {
            border: 1px solid #ddd;
        }

        th {
            padding: 10px;
            overflow: hidden;       /* 防止内容溢出 */
            text-overflow: ellipsis;/* 内容过长显示省略号 */
            white-space: nowrap;
            background-color: #f2f2f2;
            text-align: left;
        }

        td{
            font-family: Arial, sans-serif; /* 定义字体 */
            font-size: 14px;               /* 设置字体大小 */
            color: #333;                   /* 字体颜色 */
            line-height: 1.2;              /* 优化后的行间距（原1.5过密） */
            max-height: 24px;              /* 调整为合理高度（支持单行显示） */
        }
        tr:nth-child(even) {
            background-color: #f9f9f9;
        }
        tr:hover {
            background-color: #ddd;
        }
    </style>
</head>
<body>
    <h1>Search Results</h1>
    {% if source == 'Search' %}
         <form action="/search">
            <input type="text" name="q" placeholder="输入运单号"/>
             <input type="text" name="h" placeholder="输入手机号(司机)"/>
            <button type="submit" name="source" value="Search">Search</button>
         </form>
    {% elif  source == 'Search_test' %}
        <form action="/search_test">
            <input type="text" name="a" placeholder="输入运单号"/>
             <input type="text" name="h" placeholder="输入手机号(司机)"/>
            <button type="submit" name="source" value="Search_test">Search_test</button>
        </form>
    {% endif %}

    {% if message %}
        <p>{{ message }}</p>
    {% else %}
        {% if results and results|length > 0 %}
            <table>
                <thead>
                    <tr>
                        {% for key in results[0].keys() %}
                            <th>{{ key }}</th>
                        {% endfor %}
                    </tr>
                </thead>
                <tbody>
                    {% for result in results %}
                        <tr>
                            {% for value in result.values() %}
                                <td>{{ value if value is not none else '' }}</td>
                            {% endfor %}
                        </tr>
                    {% endfor %}
                </tbody>
            </table>
        {% else %}
            <p>No data available.</p>
        {% endif %}
    {% endif %}

    <a href="/">Back to Home</a>
</body>
</html>
